using System.Windows;
using Bookvar.UI.DragDrop.Actions;

namespace Bookvar.UI.DragDrop
{
    public abstract class DragSourceAdvisorBase : IDragSourceAdvisor
    {
        private UIElement sourceElement;
        private DataObject data;

        public DataObject Data
        {
            get { return data; }
            protected set { data = value; }
        }

        public UIElement SourceElement
        {
            get { return sourceElement; }
            set { sourceElement = value; }
        }

        public abstract DragDropEffects SupportedEffects
        {
            get;
        }

        public virtual DataObject GetDataObject( UIElement draggedElement, Point offsetPoint )
        {
            data = new DataObject( BookvarDataFormats.OffsetPoint.Name, offsetPoint );
            return data;
        }

        public virtual void FinishDrag( UIElement draggedElement, DragDropEffects finalEffects )
        {
            DragActionBase action = ActionFactory.CreateDragAction(draggedElement, finalEffects);
            action.Execute(draggedElement, data);
        }

        public abstract bool IsDraggable( UIElement dragElement );

        public virtual bool UseOriginalSource
        {
            get { return false; }
        }
    }
}